package com.content.management.controller.web;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.content.management.annotation.ResponseResult;
import com.content.management.biz.ContentManageService;
import com.content.management.domain.dto.PublishContentDto;
import com.content.management.domain.entity.BusPublishContent;
import com.content.management.domain.query.PublishContentQuery;
import com.content.management.domain.vo.PublishContentVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * @author xinghu
 * @version 1.0
 * @date 2020/4/4 3:55 下午
 */
@Api(tags = "公告及内容管理数据接口")
@AllArgsConstructor
@Slf4j
@ResponseResult
@RequestMapping("/011/services/manage/content")
public class ContentManageController {

	private final ContentManageService contentManageService;

	@ApiOperation(value = "分页获取内容信息或者公告信息")
	@GetMapping("page")
	public IPage<PublishContentVo> voPage(PublishContentQuery query) {
		return contentManageService.voPage(query);
	}

	@ApiOperation(value = "通过id获取内容信息或者公告信息")
	@GetMapping("getById")
	public BusPublishContent getById(@RequestParam Long id) {
		return contentManageService.getById(id);
	}


	@ApiOperation(value = "通过id删除发布的内容信息或者公告信息")
	@DeleteMapping("deleteById")
	public boolean deleteById(@RequestParam Long id) {
		return contentManageService.deleteById(id);
	}

	@ApiOperation(value = "增加或者修改发布的内容或者公告信息")
	@PostMapping("saveOrUpdateContent")
	public boolean saveOrUpdateContent(@RequestBody PublishContentDto dto) {
		return contentManageService.saveOrUpdateContent(dto);
	}

	@ApiOperation(value = "撤回内容信息或者公告信息")
	@PutMapping("withdrawById")
	public boolean withdrawById(@RequestParam Long id) {
		return contentManageService.withdrawById(id);
	}

}
